package com.yzc.util;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;

public class DocumentFactory {
	
	private static DocumentBuilder documentBuilder;
	
	static {
		DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
		try {
			documentBuilder = documentBuilderFactory.newDocumentBuilder();
		} catch (ParserConfigurationException e) {
			e.printStackTrace();
		}
	}
	
	public static Document getDocument(String url) {
		Document document = null;
		try {
			document = documentBuilder.parse(url);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return document;
	}
}
